﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace MinhUtils
{
    public class RegexHelper
    {
        /// <summary>
        /// Match all values BETWEEN before and after value
        /// </summary>
        /// <param name="input"></param>
        /// <param name="before"></param>
        /// <param name="after"></param>
        /// <param name="pattern">extra pattern to filter values</param>
        /// <returns></returns>
        public static MatchCollection MatchBeforeAfter(string input, string before, string after)
        {
            string pattern = ".*";

            return MatchBeforeAfter(input, before, after, pattern);
        }

        /// <summary>
        /// Match all values BETWEEN before and after value
        /// </summary>
        /// <param name="input"></param>
        /// <param name="before"></param>
        /// <param name="after"></param>
        /// <param name="pattern">extra pattern to filter values</param>
        /// <returns></returns>
        public static MatchCollection MatchBeforeAfter(string input, string before, string after, string pattern)
        {
            pattern = "(?<=" + before + ")" + pattern + "(?=" + after + ")";

            return Regex.Matches(input, pattern);
        }
    }
}
